package com.code.leetcode.offer;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/8/4 12:12
 */
public class The56_2 {
    public int singleNumber(int[] nums) {
        if (nums.length == 0) return 0;
        int[] bits = new int[32];


        for (int num : nums) {
            int bitmark = 1;
            for (int i = 31; i >= 0; i--) {
                bits[i] += (bitmark & num) == 0 ? 0 : 1;
                bitmark <<= 1;
            }
        }

        int res = 0;
        for (int bit : bits) {
            res <<= 1;
            res += bit % 3;
        }
        return res;
    }
}

